<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<meta name="author" content="lushu">
		<title>支票管理</title>
		<script type="text/javascript" src="../script/common.js" language="JavaScript"></script>
		<script type="text/javascript" language="JavaScript">
			var Page;					//数据表格对象
			var editForm;
			var TradeItems = [
							 ["id","交易流水号"]
							,["tradeType","交易类型"]
							,["cardAsn","卡&nbsp;&nbsp;&nbsp;&nbsp;号"]
							,["cardUserUnique","客户编号"]
							,["customerName","客户姓名"]
							,["companyName","单位名称"]
							,["amount","交&nbsp;易&nbsp;额","right"]
							,["balance","帐户余额","right"]
							];

			function load() {
				Eui.showNavigation();
				Page = {};
				Page.form = searchForm;
				editForm = $('editForm');
				Page.acquirerSetter = Clear.OrgSetter.Acquirer;
				Clear.OrgSetter.setOrgHTML("支票录入机构","acquirer");
				Page.acquirerSetter(Common.cOrg());
				Eui.initCompareInput(Page.form.id,"minAmountTd","maxAmountTd",
					"支票最小额(元)","支票最大额(元)","minMoney","maxMoney","nonNegativeAmount","ge",false);
				Common.initDict(Page.form.status, "cheque_status", "全   部");		//初始化支票验证状态(查询form)
				Common.initDict(Page.form.bank, "bank", "全   部");					//初始化银行状态(查询form)
				createTable();
				setPages(["listView","detailView"]);
			}
			function createTable() {
				var operateFunc = function(v,r){
					return "<a href=# onclick=\"showDetail('"+r[0]+"');return false;\">明细<\/a>";
				};
				var columns = [];
				columns[8] = {title:"操作",width:"5%",align:"center",render:operateFunc,order:false};
				Page.qt = new QueryTable("cheque_list", Page.form.id, "datalist", columns,
							{paramFunc:ListPage.paramFunc,exportable:true});
			}
			function showDetail(id) {
				DWR.call("tradeService.loadCheque",id,function(v){
					var cheque = v.cheque;
					Common.initDict(editForm.status, "cheque_status");
					if (cheque.status == ChequeStatus.OPEN){
						editForm.status.disabled = false;
						editForm.updateBtn.disabled = false;
						editForm.status.onchange = function(){
							if (editForm.status.value == ChequeStatus.COUNTERCANCEL){
								showWarning("此处不允许进行柜面撤销。如果支票确认无效，请设置为无效支票");
								editForm.status.value = ChequeStatus.OPEN;
							}
						}
					}
					else{
						editForm.status.disabled = true;
						editForm.updateBtn.disabled = true;
						editForm.status.style.className = 'readonly';
					}
					cheque.amount = Format.fenToYuan(cheque.amount);
					cheque.balance = Format.fenToYuan(cheque.balance);
					cheque.bank = Common.getText("bank",cheque.bank);
					Common.setValues(editForm,cheque);
					var trades = v.trades;
					if(trades){
						$("subTradesList").innerHTML = DetailPage.Misc.List2Table(trades,TradeItems,DetailPage._transferTradeDetails);
					}
					switchPage("detailView");
				});
			}
			function update(){
				var data = Common.getValues(editForm);
				if(data.status == ChequeStatus.OPEN){
					showListPage();
					return;
				}
				var flag = true;
				if(data.status == ChequeStatus.VALIDITY && data.balance!=0){
					flag = showQuestion("该支票目前的余额不为0。确定使支票生效？");
				}
				if(flag){
					DWR.call("tradeService.validateCheque",
						data.id,
						data.status,
						function(v){
							showInformation("支票状态修改成功");
							showListPage();
						}
					);
				}
			}
			function showListPage(){
				editForm.reset();
				switchPage("listView");
				Page.qt.showTable();
			}
		</script>
	</head>
	<body onload="load()">
		<div class="nav"><div id="nav">&nbsp;</div></div>
	
		<div id="listView">
			<div class="searchForm">
				<form id="searchForm" name="searchForm">
					<table cellSpacing="0" cellPadding="4" width="100%" border="0">
						<tr>
							<td class="label7" id="acquirer"></td>
							<td class="label7">
								<label>支票所属银行</label>
								<select name="bank"><option></option></select>
							</td>
							<td>
								<label>支 票 号</label>
								<input type="text" name="chequeNo" onblur="checkV(this,'long');">
							</td>
							<td></td>
						</tr>
						<tr>
							<td class="label7" id="minAmountTd"></td>
							<td class="label7" id="maxAmountTd"></td>
							<td>
								<label>支票状态</label>
								<select name="status"><option></option></select>
							</td>
							<td><button onclick="Page.qt.showTable()">查 询</button></td>
						</tr>
					</table>
				</form>
			</div>
			<div id="datalist"></div>
		</div>
		
		<div id="detailView" style="display:none;">
			<div class="form">
				<div class="formTitle">支票信息</div>
				<form id="editForm" name="editForm">
					<input type="hidden" name="id">
					<table cellSpacing="0" cellPadding="4" width="100%" border="0" class="col2 label6">
						<tr>
							<td>
								<label>支票所属银行</label>
								<input type="text" name="bank" disabled class="readonly">
							</td>
							<td>
								<label>支 票 号</label>
								<input type="text" disabled name="chequeNo" class="readonly">
							</td>
						</tr>
						<tr>
							<td>
								<label>支票金额</label>
								<input type="text" name="amount" disabled class="readonly"> 元
							</td>
							<td>
								<label>支票余额</label>
								<input type="text" name="balance" disabled class="readonly"> 元
							</td>
						</tr>
						<tr>
							<td>
								<label>录 入 员</label>
								<input type="text" name="operName" disabled class="readonly">
							</td>
							<td>
								<label>录入时间</label>
								<input type="text" name="recordTime" disabled class="readonly">
							</td>
						</tr>
						<tr>
							<td>
								<label>支票录入机构</label>
								<input type="text" name="acquirerName" disabled class="readonly">
							</td>
							<td>
								<label>支票状态</label>
								<select name="status"><option></option></select>
							</td>
						</tr>
					</table>
					<p>
						<button name="updateBtn" onClick="update()">确 定</button>
						<button onClick="showListPage()">返 回</button>
					</p>
					<div id="relatedTrades"/></div>
				</form>
			</div>
			<div class="form" id="subTradesDiv">
				<div class="formTitle">
					<span id="subTradesTitle">支票关联交易</span>
				</div>
				<div id="subTradesList"></div>
			</div>
		</div>
	</body>
</html>